const rp = require('request-promise');

module.exports = class extends think.Service {
  async getShenfenInfo(no, name) {
    try {
      // 获取 session
      const options = {
        method: 'POST',
        uri: 'http://checkone.market.alicloudapi.com/chinadatapay/1882',
        headers: {
          'Authorization': 'APPCODE be150a235df148b2a256553f478fdefb'
        },
        form: {
          'idcard': '' + no,
          'name': name
        },
        json: true
      };
      const sessionData = await rp(options);

      // sessionData = JSON.parse(sessionData);
      // if (!sessionData.openid) {
      //   return null;
      // }
      return sessionData;
    } catch (e) {
      console.log(e);
      return null;
    }
  }
};
